<!DOCTYPE html><html lang="zh" >


<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  
  
  
    <meta name="generator" content="Wowchemy 5.6.0 for Hugo" />
  

  
  












  
  










  







  
  
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  

  
  
  
    
      
      <link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Merriweather&family=Roboto+Mono&display=swap">
      <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Merriweather&family=Roboto+Mono&display=swap" media="print" onload="this.media='all'">
    
  

  
  
  
  
  
  

  

  
  
  
    
  
  <meta name="description" content="简介 centos挂载iso文件作为yum安装源 上传系统iso" />

  
  <link rel="alternate" hreflang="zh" href="https://songchuanrang.gitee.io/docs/centos%E6%8C%82%E8%BD%BDiso%E6%96%87%E4%BB%B6%E4%BD%9C%E4%B8%BAyum%E5%AE%89%E8%A3%85%E6%BA%90/" />

  
  
  
    <meta name="theme-color" content="#1565c0" />
  

  
  

  

  <link rel="stylesheet" href="/css/vendor-bundle.min.c7b8d9abd591ba2253ea42747e3ac3f5.css" media="print" onload="this.media='all'">

  
  
  
    
    

    
    
    
    
      
      
    
    
    

    
    
    

    

    
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
      
      

      
      
        
      

      
    
      
      

      
      

      
    
      
      

      
      

      
    
  

  
  
  
  
  
  
  <link rel="stylesheet" href="/css/wowchemy.50151d350c96d255e89f810190000890.css" />

  
  
  
  
  
  
  
    
    
    <link rel="stylesheet" href="/css/libs/chroma/github-light.min.css" title="hl-light" media="print" onload="this.media='all'" >
    <link rel="stylesheet" href="/css/libs/chroma/dracula.min.css" title="hl-dark" media="print" onload="this.media='all'" disabled>
  

  
  



  


  


  




  
  
  

  
  

  
  
    <link rel="manifest" href="/manifest.webmanifest" />
  

  
  <link rel="icon" type="image/png" href="/media/icon_huec9f8681c90e5958ea60dec1a7d5fe8a_15532_32x32_fill_lanczos_center_3.png" />
  <link rel="apple-touch-icon" type="image/png" href="/media/icon_huec9f8681c90e5958ea60dec1a7d5fe8a_15532_180x180_fill_lanczos_center_3.png" />

  <link rel="canonical" href="https://songchuanrang.gitee.io/docs/centos%E6%8C%82%E8%BD%BDiso%E6%96%87%E4%BB%B6%E4%BD%9C%E4%B8%BAyum%E5%AE%89%E8%A3%85%E6%BA%90/" />

  
  
  
  
  
  
  
  
    
    
  
  

  
  
    
    
  
  <meta property="twitter:card" content="summary" />
  
    <meta property="twitter:site" content="@wowchemy" />
    <meta property="twitter:creator" content="@wowchemy" />
  
  <meta property="og:site_name" content="学习分享" />
  <meta property="og:url" content="https://songchuanrang.gitee.io/docs/centos%E6%8C%82%E8%BD%BDiso%E6%96%87%E4%BB%B6%E4%BD%9C%E4%B8%BAyum%E5%AE%89%E8%A3%85%E6%BA%90/" />
  <meta property="og:title" content="centos挂载iso文件作为yum安装源 | 学习分享" />
  <meta property="og:description" content="简介 centos挂载iso文件作为yum安装源 上传系统iso" /><meta property="og:image" content="https://songchuanrang.gitee.io/media/icon_huec9f8681c90e5958ea60dec1a7d5fe8a_15532_512x512_fill_lanczos_center_3.png" />
    <meta property="twitter:image" content="https://songchuanrang.gitee.io/media/icon_huec9f8681c90e5958ea60dec1a7d5fe8a_15532_512x512_fill_lanczos_center_3.png" /><meta property="og:locale" content="zh" />
  
    
      <meta
        property="article:published_time"
        content="2023-02-11T19:37:25&#43;08:00"
      />
    
    <meta property="article:modified_time" content="2023-02-11T19:37:25&#43;08:00">
  

  



  

  


  <title>centos挂载iso文件作为yum安装源 | 学习分享</title>

  
  
  
  











</head>


<body id="top" data-spy="scroll" data-offset="70" data-target="#TableOfContents" class="page-wrapper   " data-wc-page-id="d81e3cfa5a87823dee0dac58bef839ea" >

  
  
  
  
  
  
  
  
  
  <script src="/js/wowchemy-init.min.613040fe4f2c0f007b4dcb64404201cb.js"></script>

  


<aside class="search-modal" id="search">
  <div class="container">
    <section class="search-header">

      <div class="row no-gutters justify-content-between mb-3">
        <div class="col-6">
          <h1>搜索</h1>
        </div>
        <div class="col-6 col-search-close">
          <a class="js-search" href="#" aria-label="Close"><i class="fas fa-times-circle text-muted" aria-hidden="true"></i></a>
        </div>
      </div>

      <div id="search-box">
        
        <input name="q" id="search-query" placeholder="搜索..." autocapitalize="off"
        autocomplete="off" autocorrect="off" spellcheck="false" type="search" class="form-control"
        aria-label="搜索...">
        
      </div>

      
      

      

    </section>
    <section class="section-search-results">

      <div id="search-hits">
        
      </div>

    </section>
  </div>
</aside>



  <div class="page-header">
    












<header class="header--fixed">
  <nav class="navbar navbar-expand-lg navbar-light compensate-for-scrollbar" id="navbar-main">
    <div class="container-xl">

      
      <div class="d-none d-lg-inline-flex">
        <a class="navbar-brand" href="/">学习分享</a>
      </div>
      

      

      
      <div class="navbar-brand-mobile-wrapper d-inline-flex d-lg-none">
        <a class="navbar-brand" href="/">学习分享</a>
      </div>
      

      
      
      <div class="navbar-collapse main-menu-item collapse justify-content-start" id="navbar-content">

        
        <ul class="navbar-nav d-md-inline-flex">
          

        

          
        </ul>
      </div>

      <ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">

        
        

        
        
        <li class="nav-item">
          <a class="nav-link js-search" href="#" aria-label="搜索"><i class="fas fa-search" aria-hidden="true"></i></a>
        </li>
        

        
        
        
        <li class="nav-item dropdown theme-dropdown">
          <a href="#" class="nav-link" data-toggle="dropdown" aria-haspopup="true" aria-label="Display preferences">
            <i class="fas fa-moon" aria-hidden="true"></i>
          </a>
          <div class="dropdown-menu">
            <a href="#" class="dropdown-item js-set-theme-light">
              <span>浅色</span>
            </a>
            <a href="#" class="dropdown-item js-set-theme-dark">
              <span>深色</span>
            </a>
            <a href="#" class="dropdown-item js-set-theme-auto">
              <span>自动</span>
            </a>
          </div>
        </li>
        

        
        

      </ul>

    </div>
  </nav>
</header>


  </div>

  <div class="page-body">
    
    
    

    




<div class="container-fluid docs">
  <div class="row flex-xl-nowrap">
    <div class="col-12 col-md-3 col-xl-2 docs-sidebar">
      <form class="docs-search d-flex align-items-center">
  <button class="btn docs-toggle d-md-none p-0 mr-md-3 w-100" type="button" data-toggle="collapse" data-target="#docs-nav" aria-controls="docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
    <div class="d-flex">
      <span class="d-md-none pl-1 flex-grow-1 text-left overflow-hidden">
        
        
          Docs
        
      </span>
      <span><i class="fas fa-chevron-down"></i></span>
    </div>
  </button>

  
  <button class="form-control sidebar-search js-search d-none d-md-flex">
    <i class="fas fa-search pr-2"></i>
    <span class="sidebar-search-text">搜索...</span>
    <span class="sidebar-search-shortcut">/</span>
  </button>
  
</form>

<nav class="collapse docs-links" id="docs-nav">
  
  
  
  
  
  

  
  
    





  
    
    
    
    
      
    
    

    
      <div class="docs-toc-item">
        <a class="docs-toc-link " href="/docs/">Docs</a>
    
      
        <ul class="nav docs-sidenav">
      


  <li class=""><a href="/docs/tomcat/">tomcat</a></li>



  <li class=""><a href="/docs/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a></li>



  <li class="active"><a href="/docs/centos%E6%8C%82%E8%BD%BDiso%E6%96%87%E4%BB%B6%E4%BD%9C%E4%B8%BAyum%E5%AE%89%E8%A3%85%E6%BA%90/">centos挂载iso文件作为yum安装源</a></li>



  <li class=""><a href="/docs/java-nio/">JAVA NIO</a></li>



  <li class=""><a href="/docs/div%E5%B8%83%E5%B1%80/">div盒子模型及html布局</a></li>



  <li class=""><a href="/docs/nginx/">nginx安装及配置</a></li>



  <li class=""><a href="/docs/gc%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90gcviewer/">GC日志分析之GCViewer</a></li>

      
        </ul>
      
    

    
      </div>
    

</nav>

    </div>

    
    
    <div class="d-none d-xl-block col-xl-3 docs-toc">
      












      <ul class="nav toc-top">
        <li><a href="#" id="back_to_top" class="docs-toc-title">在本页</a></li>
      </ul>

      <nav id="TableOfContents">
  <ul>
    <li><a href="#简介">简介</a></li>
    <li><a href="#上传系统iso文件">上传系统iso文件</a></li>
    <li><a href="#创建挂载目录">创建挂载目录</a></li>
    <li><a href="#挂载镜像文件">挂载镜像文件</a></li>
    <li><a href="#持久化挂载文件">持久化挂载文件</a></li>
    <li><a href="#新增文件etcyumreposdcentos7-localrepo">新增文件/etc/yum.repos.d/CentOS7-Local.repo</a></li>
    <li><a href="#备份etcyumreposdcentos-baserepo">备份/etc/yum.repos.d/CentOS-Base.repo</a></li>
    <li><a href="#清除yum缓存">清除yum缓存</a></li>
  </ul>
</nav>

      











    </div>
    

    <main class="col-12 col-md-9 col-xl-7 py-md-3 pl-md-5 docs-content" role="main">

      <article class="article">

        <div class="docs-article-container">
          
            
  <nav class="d-none d-md-flex" aria-label="breadcrumb">
    <ol class="breadcrumb">
      
  
    
  
    
  

    <li class="breadcrumb-item">
      <a href="/">
        
          Home
        
      </a>
    </li>
  

    <li class="breadcrumb-item">
      <a href="/docs/">
        
          Docs
        
      </a>
    </li>
  

      <li class="breadcrumb-item active" aria-current="page">
        centos挂载iso文件作为yum安装源
      </li>
    </ol>
  </nav>




          
        </div>

        
        

        <div class="docs-article-container">
          
          <h1>centos挂载iso文件作为yum安装源</h1>

          <div class="article-style">

            
            

            <h2 id="简介">简介</h2>
<p>centos挂载iso文件作为yum安装源</p>
<h2 id="上传系统iso文件">上传系统iso文件</h2>
<p>例如系统文件名：CentOS-7-x86_64-DVD-2207-02.iso</p>
<h2 id="创建挂载目录">创建挂载目录</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mkdir -p /media/CentOS7
</span></span></code></pre></div><h2 id="挂载镜像文件">挂载镜像文件</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mount -t iso9660 -o loop /path/to/CentOS-7-x86_64-DVD-2207-02.iso /media/CentOS7
</span></span></code></pre></div><h2 id="持久化挂载文件">持久化挂载文件</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">vi /etc/fstab
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">/path/to/CentOS-7-x86_64-DVD-2207-02.iso /media/CentOS7 iso9660 defaults,ro,loop 0 0
</span></span></code></pre></div><h2 id="新增文件etcyumreposdcentos7-localrepo">新增文件/etc/yum.repos.d/CentOS7-Local.repo</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">vi /etc/yum.repos.d/CentOS7-Local.repo
</span></span><span class="line"><span class="cl"><span class="o">[</span>CentOS7-Local<span class="o">]</span>
</span></span><span class="line"><span class="cl"><span class="nv">name</span><span class="o">=</span>CentOS7
</span></span><span class="line"><span class="cl"><span class="nv">baseurl</span><span class="o">=</span>file:///media/CentOS7
</span></span><span class="line"><span class="cl"><span class="nv">enabled</span><span class="o">=</span><span class="m">1</span>
</span></span><span class="line"><span class="cl"><span class="nv">gpgcheck</span><span class="o">=</span><span class="m">0</span>
</span></span><span class="line"><span class="cl"><span class="nv">gpgkey</span><span class="o">=</span>file:///media/CentOS7/RPM-GPG-KEY-CentOS-7
</span></span></code></pre></div><h2 id="备份etcyumreposdcentos-baserepo">备份/etc/yum.repos.d/CentOS-Base.repo</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
</span></span></code></pre></div><p>这里CentOS-Base.repo文件主要是去网络上找相应的包，修改为从本地源读取</p>
<h2 id="清除yum缓存">清除yum缓存</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">yum clean all
</span></span></code></pre></div>

          </div>

          



          
          
          <div class="article-widget">
            
<div class="post-nav">
  
  
  
  <div class="post-nav-item">
    <div class="meta-nav">上一页</div>
    <a href="/docs/nginx/" rel="next">nginx安装及配置</a>
  </div>
  
  
  
  <div class="post-nav-item">
    <div class="meta-nav">下一页</div>
    <a href="/docs/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" rel="prev">设计模式</a>
  </div>
  
</div>

          </div>
          
        </div>

        <div class="body-footer">
          <p>最近更新于 2023/2/11</p>

          






  

<p class="edit-page">
  <a href="https://github.com/songchuanrang/songchuanrang.github.io/edit/main/content/docs%5ccentos%e6%8c%82%e8%bd%bdiso%e6%96%87%e4%bb%b6%e4%bd%9c%e4%b8%bayum%e5%ae%89%e8%a3%85%e6%ba%90.md">
    <i class="fas fa-pen pr-2"></i>编辑本页
  </a>
</p>



          




          


        </div>

      </article>

      <footer class="site-footer">

  












  

  

  

  
  






  
  
  

  
  
    
  
  
    
  

  

  
  <p class="powered-by copyright-license-text">
    © 2023 songchuanrang. This work is licensed under <a href="https://creativecommons.org/licenses/by-nc-nd/4.0" rel="noopener noreferrer" target="_blank">CC BY NC ND 4.0</a>
  </p>
  

  <p class="powered-by footer-license-icons">
    <a href="https://creativecommons.org/licenses/by-nc-nd/4.0" rel="noopener noreferrer" target="_blank" aria-label="Creative Commons">
      <i class="fab fa-creative-commons fa-2x" aria-hidden="true"></i>
      <i class="fab fa-creative-commons-by fa-2x" aria-hidden="true"></i>
      
        <i class="fab fa-creative-commons-nc fa-2x" aria-hidden="true"></i>
      
      
        <i class="fab fa-creative-commons-nd fa-2x" aria-hidden="true"></i>
      
    </a>
  </p>




  <p class="powered-by">
    
    
    
      
      
      
      
      
      
      由<a href="https://wowchemy.com/?utm_campaign=poweredby" target="_blank" rel="noopener">Wowchemy</a>支持发布——免费<a href="https://github.com/wowchemy/wowchemy-hugo-themes" target="_blank" rel="noopener">开源</a>网站，为创作者赋能。
    
  </p>
</footer>


    </main>
  </div>
</div>

  </div>

  <div class="page-footer">
    
    
  </div>

  


<script src="/js/vendor-bundle.min.32ee83730ed883becad04bc5170512cc.js"></script>




  

  
  

  









<script src="https://cdn.jsdelivr.net/npm/anchor-js@5.0.0/anchor.min.js" integrity="sha256-aQmOEF2ZD4NM/xt4hthzREIo/2PFkOX/g01WjxEV7Ys=" crossorigin="anonymous"></script>
<script>
  anchors.add();
</script>





  
  <script id="search-hit-fuse-template" type="text/x-template">
    <div class="search-hit" id="summary-{{key}}">
      <div class="search-hit-content">
        <div class="search-hit-name">
          <a href="{{relpermalink}}">{{title}}</a>
          <div class="article-metadata search-hit-type">{{type}}</div>
          <p class="search-hit-description">{{snippet}}</p>
        </div>
      </div>
    </div>
  </script>
  
    <script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@v3.2.1/dist/fuse.min.js" integrity="sha512-o38bmzBGX+hD3JHWUFCDA09btWaqrNmoJ3RXLlrysA7PP01Kgs4UlE4MhelE1v5dJR3+cxlR4qQlotsW7jKsnw==" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/gh/julmot/mark.js@8.11.1/dist/jquery.mark.min.js" integrity="sha512-mhbv5DqBMgrWL+32MmsDOt/OAvqr/cHimk6B8y/bx/xS88MVkYGPiVv2ixKVrkywF2qHplNRUvFsAHUdxZ3Krg==" crossorigin="anonymous"></script>
  












  
  
  
  
  
  
  







<script id="page-data" type="application/json">{"use_headroom":false}</script>











  
  


<script src="/zh/js/wowchemy.min.4e5e27caa14e13784384b84ea7186f46.js"></script>























</body>
</html>
